/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-11-5      Ghazigq       first version
 */

#ifndef __DRV_SPI_H_
#define __DRV_SPI_H_

#include <rtthread.h>
#include "rtdevice.h"
#include <rthw.h>
#include <drv_common.h>

rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, uint32_t cs_pin);

#define SPI_USING_RX_DMA_FLAG   (1<<0)
#define SPI_USING_TX_DMA_FLAG   (1<<1)

struct nrf_spi_config
{
    const nrfx_spim_t p_instance;  /**< SPI instance. */
    char *bus_name;
    rt_uint32_t sck_pin;
    rt_uint32_t mosi_pin;
    rt_uint32_t miso_pin;
    rt_sem_t sem;
    uint8_t init;
};

/* nrf spi dirver class */
struct nrf_spi
{
    struct nrf_spi_config *config;
    struct rt_spi_configuration *cfg;
    struct rt_spi_bus spi_bus;
};

#endif /*__DRV_SPI_H_ */
